<html xmlns="http://www.w3.org/1999/xhtml"
	xmlns:h="http://java.sun.com/jsf/html"
	xmlns:ui="http://java.sun.com/jsf/facelets"
	xmlns:f="http://java.sun.com/jsf/core">
<h:head>
	<ui:include src="include/head.xhtml" />
</h:head>
<h:body>
	<ui:include src="include/header.xhtml" />
	<div class="main">
		<table width="100%">
			<tr>
				<td width="15%" valign="top">
					<ui:include src="include/menu.xhtml" />
				</td>
				<td class="main" valign="top">
					<div class='panel-header'>
						Успеваемость группы #{progressBean.group.title}, #{progressBean.group.term} семестр 
					</div>
					<br />
					<table width='100%'>
						<tr>
							<td width='20%' valign="top">
								<div class="panel-header">Выберите предмет:</div> 
								<h:dataTable value="#{progressBean.planItems.items}" var="pi"
									binding="#{progressBean.planItems.dataTable}">
									<h:column>
										<a class="#{progressBean.planItems.style}" 
										   href="http://localhost:8080/university-web/progress/#{progressBean.group.id}/#{pi.subject.id}">
											#{pi.subject.title}
										</a>
									</h:column>
								</h:dataTable>
							</td>
							<td valign="top">
								<h:form>
								<div class="panel-header">Успеваемость:</div>
								<table width='100%' class='progressTable'>
									<ui:repeat value="#{progressBean.progressRows}" var="pr">
										<tr>
											<td class='progressTable' width='10%'>
											   <b>#{pr.student.fullName}</b>
											</td>
											<ui:repeat value="#{pr.progress}" var="pw">
												<td class='progressTable'>
													<h:outputText value="#{pw.progress.mark}" 
																 rendered="#{!progressBean.editMode}"/>
													<h:selectOneMenu value="#{pw.mark}" 
																	 rendered='#{progressBean.editMode}'>
														<f:selectItems value="#{pw.marks}" />
													</h:selectOneMenu>
												</td>
											</ui:repeat>
										</tr>
									</ui:repeat>	
								</table>
								<br />
								<h:commandButton value='Сохранить' 
									 action='#{progressBean.save}' 
									 rendered='#{progressBean.editMode}'/>
								<h:commandButton value='Завершить' 
					                 action='#{progressBean.finishEdit}' 
					                 rendered='#{progressBean.editMode}' />
								<h:commandButton value='Изменить' 
									 action='#{progressBean.edit}' 
									 rendered="#{authBean.loggedInAsTeacher and !progressBean.editMode}" />
								</h:form>
							</td>
						</tr>
						</table>
					<h:messages />
				</td>
			</tr>
		</table>
	</div>
</h:body>
</html>